import { useEffect, useState } from 'react'
import { getChannelAPI } from '@/apis/article'

/**
 * 自定义hook，获取频道列表
 * @returns {Object} 包含频道列表的对象
 */
function useChannel() {

    const [channelList, setChannelList] = useState([])
    useEffect(() => {
        const getChannelList = async () => {
            const res = await getChannelAPI()
            setChannelList(res.data.channels)
        }
        getChannelList()
    }, [])


    return { channelList }
}

export {
    useChannel
}